package com.srzk.youthleagueback.utils;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class ObjectUtil {
    public static Map<String, Object> reflect(Object e) throws Exception {
        Class cls = e.getClass();
        Field[] fields = cls.getDeclaredFields();
        Map<String, Object> result = new HashMap<>();
        for (int i = 0; i < fields.length; i++) {
            Field f = fields[i];
            f.setAccessible(true);
            result.put(f.getName(), f.get(e));
        }
        return result;
    }
    //2018级软件工程3班团支部
    public static String getClass (String user){
        int index = user.indexOf("班");
        return user.substring(index-1,index);
    }

    public static String getGrade (String user){
        int index = user.indexOf("级");
        return user.substring(0,index);
    }
}

